<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<script type="text/javascript">

jQuery(document).ready(function() {
    DomainProcessor.init();
});

if (typeof (DomainProcessor) == 'undefined') {
    var DomainProcessor = {
        columns : [],
        processInsertResponse : function(response, postdata) {
            var success = true;
            var msg = "";
            if(response.responseText != "") {
                var obj = jQuery.parseJSON(response.responseText);
                if(obj != null && obj.error !== undefined) {
                    success = false;
                    
                    msg = "<ul>";
                    $.each(obj.error, function(index, value) {
                        msg += "<li>" + value + "</li>";
                    });
                    msg += "</ul>";
                }
            }
            return [success, msg, null];
        },
        processUpdateResponse : function(response) {
            var success = true;
            var msg = "";
            if(response.responseText != "") {
                var obj = jQuery.parseJSON(response.responseText);
                if(obj != null && obj.error !== undefined) {
                    success = false;
                    
                    msg = "";
                    $.each(obj.error, function(index, value) {
                        if (index > 0) {
                            msg += "\n";
                        }
                        msg += value;
                    });
                    alert(msg);
                }
            }
            return success;
        },
        init : function() {
            jQuery("#gridContainer").jqGrid({
                ajaxGridOptions : {
                    type : 'POST',
                    contentType : 'application/json'
                },
                ajaxRowOptions : {
                    type : 'POST',
                    contentType : 'application/json'
                },
                serializeRowData : function(postdata) {
                    return $.toJSON(postdata);
                },
                serializeGridData : function(postdata) {
                    if(postdata.search == true) {
                        if(DomainProcessor.columns.length == 0) {
                            var colModel = jQuery("#gridContainer").jqGrid('getGridParam','colModel');
                            $.each(colModel, function(i, item) {
                                DomainProcessor.columns.push(item.name);
                            });
                        }
                        
                        var transformedPostData = {};
                        var objectJson = new Object;
                        
                        $.each(postdata, function(i, item) {
                            if(-1 != jQuery.inArray(i, DomainProcessor.columns)) {
                                if(objectJson['criteria'] == undefined) {
                                    objectJson['criteria'] = {};
                                }
                                objectJson['criteria'][i] = item;
                            } else {
                                objectJson[i] = item;
                            }
                        });
                        
                        postdata = objectJson;
                    }
                    return $.toJSON(postdata);
                },
                url : 'management/index.action',
                editurl : 'management/update.action',
                jsonReader: {
                    root : 'gridData',
                    page : 'currPage',
                    total : 'totalPages',
                    records : 'totalRecords',
                    repeatitems : false
                },
                datatype : 'json',
                colNames : [ 
                             '#',
                             '<spring:message code="Book.book.acquiredfrom"/>',
                             '<spring:message code="Book.book.author"/>',
                             '<spring:message code="Book.book.authorsort"/>',
                             '<spring:message code="Book.book.binding"/>',
                             '<spring:message code="Book.book.borrower"/>',
                             '<spring:message code="Book.book.category"/>',
                             '<spring:message code="Book.book.comment"/>',
                             '<spring:message code="Book.book.contributor"/>',
                             '<spring:message code="Book.book.contributorsort"/>',
                             '<spring:message code="Book.book.country"/>',
                             '<spring:message code="Book.book.custom01"/>',
                             '<spring:message code="Book.book.custom02"/>',
                             '<spring:message code="Book.book.custom03"/>',
                             '<spring:message code="Book.book.custom04"/>',
                             '<spring:message code="Book.book.custom05"/>',
                             '<spring:message code="Book.book.custom06"/>',
                             '<spring:message code="Book.book.custom07"/>',
                             '<spring:message code="Book.book.custom08"/>',
                             '<spring:message code="Book.book.dateborrowed"/>',
                             '<spring:message code="Book.book.datedue"/>',
                             '<spring:message code="Book.book.datepurchased"/>',
                             '<spring:message code="Book.book.edition"/>',
                             '<spring:message code="Book.book.editor"/>',
                             '<spring:message code="Book.book.editorsort"/>',
                             '<spring:message code="Book.book.ghostwriter"/>',
                             '<spring:message code="Book.book.ghostwritersort"/>',
                             '<spring:message code="Book.book.isbn"/>',
                             '<spring:message code="Book.book.keywords"/>',
                             '<spring:message code="Book.book.lccn"/>',
                             '<spring:message code="Book.book.language"/>',
                             '<spring:message code="Book.book.location"/>',
                             '<spring:message code="Book.book.marked"/>',
                             '<spring:message code="Book.book.modified"/>',
                             '<spring:message code="Book.book.originalcountry"/>',
                             '<spring:message code="Book.book.originaldate"/>',
                             '<spring:message code="Book.book.originallanguage"/>',
                             '<spring:message code="Book.book.originalpublisher"/>',
                             '<spring:message code="Book.book.originaltitle"/>',
                             '<spring:message code="Book.book.overview"/>',
                             '<spring:message code="Book.book.owner"/>',
                             '<spring:message code="Book.book.pages"/>',
                             '<spring:message code="Book.book.picture"/>',
                             '<spring:message code="Book.book.price"/>',
                             '<spring:message code="Book.book.printedby"/>',
                             '<spring:message code="Book.book.printing"/>',
                             '<spring:message code="Book.book.publishdate"/>',
                             '<spring:message code="Book.book.publisher"/>',
                             '<spring:message code="Book.book.rating"/>',
                             '<spring:message code="Book.book.read"/>',
                             '<spring:message code="Book.book.readwhen"/>',
                             '<spring:message code="Book.book.referenceno"/>',
                             '<spring:message code="Book.book.review"/>',
                             '<spring:message code="Book.book.status"/>',
                             '<spring:message code="Book.book.subcategory"/>',
                             '<spring:message code="Book.book.subtitle"/>',
                             '<spring:message code="Book.book.title"/>',
                             '<spring:message code="Book.book.titlesort"/>',
                             '<spring:message code="Book.book.translator"/>',
                             '<spring:message code="Book.book.translatorsort"/>',
                             '<spring:message code="Book.book.type"/>',
                             '<spring:message code="Book.book.url"/>',
                             '<spring:message code="Book.book.value"/>',
                             '<spring:message code="Book.book.year"/>'
                             ],
                             colModel : [ 
     									
		 										{
		 										name : 'id',
		 			                            index : 'id',
		 			                            width : 6,
		 			                            key : true,
		 			                            hidden : true
		 										},										
												
		 										{
	 											name: 'acquiredfrom',
	 											index: 'acquiredfrom',
	 											width:700,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'author',
	 											index: 'author',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 							                title: false,
	 											search: true,
 							                    searchoptions : {
 							                        dataEvents:[{type:'keyup', fn: doSearch}]
 							                    }
 											},
 											{
	 											name: 'authorsort',
	 											index: 'authorsort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'binding',
	 											index: 'binding',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'borrower',
	 											index: 'borrower',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'category',
	 											index: 'category',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'comment',
	 											index: 'comment',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'contributor',
	 											index: 'contributor',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'contributorsort',
	 											index: 'contributorsort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'country',
	 											index: 'country',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom01',
	 											index: 'custom01',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom02',
	 											index: 'custom02',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom03',
	 											index: 'custom03',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom04',
	 											index: 'custom04',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom05',
	 											index: 'custom05',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom06',
	 											index: 'custom06',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom07',
	 											index: 'custom07',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'custom08',
	 											index: 'custom08',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'dateborrowed',
	 											index: 'dateborrowed',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'datedue',
	 											index: 'datedue',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'datepurchased',
	 											index: 'datepurchased',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'edition',
	 											index: 'edition',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'editor',
	 											index: 'editor',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'editorsort',
	 											index: 'editorsort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'ghostwriter',
	 											index: 'ghostwriter',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'ghostwritersort',
	 											index: 'ghostwritersort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'isbn',
	 											index: 'isbn',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'keywords',
	 											index: 'keywords',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'lccn',
	 											index: 'lccn',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'language',
	 											index: 'language',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'location',
	 											index: 'location',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'marked',
	 											index: 'marked',
	 											width:30,
	 											align: 'left',
	 						                    formatter:'checkbox',
	 						                    search: false,
	 						                    editable : true,
	 						                    edittype:'checkbox',
	 						                    editoptions: { value:"true:false" },
	 						                    editrules : {edithidden:true, required:false},
	 											hidden: true 
	 											},

	 											{
	 											name: 'modified',
	 											index: 'modified',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'originalcountry',
	 											index: 'originalcountry',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'originaldate',
	 											index: 'originaldate',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'originallanguage',
	 											index: 'originallanguage',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'originalpublisher',
	 											index: 'originalpublisher',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'originaltitle',
	 											index: 'originaltitle',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'overview',
	 											index: 'overview',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'owner',
	 											index: 'owner',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'pages',
	 											index: 'pages',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'picture',
	 											index: 'picture',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'price',
	 											index: 'price',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'printedby',
	 											index: 'printedby',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'printing',
	 											index: 'printing',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'publishdate',
	 											index: 'publishdate',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'publisher',
	 											index: 'publisher',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'rating',
	 											index: 'rating',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'read',
	 											index: 'read',
	 											width:30,
	 											align: 'left',
	 						                    formatter:'checkbox',
	 						                    search: false,
	 						                    editable : true,
	 						                    edittype:'checkbox',
	 						                    editoptions: { value:"true:false" },
	 						                    editrules : {edithidden:true, required:false},
	 											hidden: true 
	 											},

	 											{
	 											name: 'readwhen',
	 											index: 'readwhen',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'referenceno',
	 											index: 'referenceno',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'review',
	 											index: 'review',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'status',
	 											index: 'status',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'subcategory',
	 											index: 'subcategory',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'subtitle',
	 											index: 'subtitle',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'title',
	 											index: 'title',
	 											width:80,
	 											align: 'left',
	 							                title: false,
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											search: true,
 							                    searchoptions : {
 							                        dataEvents:[{type:'keyup', fn: doSearch}]
 							                    }
 											},
 											{
	 											name: 'titlesort',
	 											index: 'titlesort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'translator',
	 											index: 'translator',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'translatorsort',
	 											index: 'translatorsort',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'type',
	 											index: 'type',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'url',
	 											index: 'url',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'value',
	 											index: 'value',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											},

	 											{
	 											name: 'year',
	 											index: 'year',
	 											width:80,
	 											align: 'left',
	 											sortable: true,
	 											editable: true,
	 											edittype: 'text',
	 											editrules: {edithidden:true},
	 											hidden: true 
	 											}           
                ],
                viewrecords: true,
                rowNum : ${sessionScope.gridRowNum != null ? sessionScope.gridRowNum : 20 },
                width : 940,
                height: 'auto',
                rowList : [ 10, 20, 30, 50, 100, 200 ],
                pager : '#pagerGridContainer',
                viewrecords : true,
                caption : '<spring:message code="Book.page.title" />',
                prmNames : {
                    search : "search",
                    order : "order",
                    oper : "action",
                    sort : "sort"
                },
                onPaging : function (pgButton) {
                    if (pgButton == "records") {
                        var newRowNum = $("#gridContainer").jqGrid('getGridParam', 'rowNum');
                        updatePreferedRowNum(newRowNum);
                    }
                    return pgButton;
                },
                loadComplete: function(){                	
                	var ids = jQuery("#gridContainer").jqGrid('getDataIDs');
                	var myGrid = jQuery("#gridContainer");
                	$('#.jqgrow *').removeAttr("title");
                	
                	for (var i = 0; i < ids.length; i++) {
                	    var id=ids[i];
                	    var contents='<table><tr><td valign="top" width="300">' +
                	    '<b>Author: </b>' + myGrid.jqGrid('getCell',id,'author') + '<br/>' +
                	    '<b>Title: </b>' + myGrid.jqGrid('getCell',id,'title') + '<br/>' +
                	    '<b>Category: </b>' + myGrid.jqGrid('getCell',id,'category') + '<br/>' +
                	    '<b>Language: </b>' + myGrid.jqGrid('getCell',id,'language') + '<br/>' +
                	    '<b>Modified: </b>' + myGrid.jqGrid('getCell',id,'modified') + '<br/>' +
                	    '<b>Pages: </b>' + myGrid.jqGrid('getCell',id,'pages') + '<br/>' +
                        '<b>Year: </b>' + myGrid.jqGrid('getCell',id,'year') +
                	    	'</td><td width="300"><img src="http://www.istockphoto.com/file_thumbview_approve/1802740/2/istockphoto_1802740-gold-pocket-watch.jpg" align="right" width="304" height="380"/></td></tr></table>';
                	    $("#" + id).qtip({
                            content: contents,
                            position: {
                            	adjust: { screen: true, resize: true },
                               corner: {
                                  tooltip: 'bottomMiddle',
                                  target: 'topMiddle'
                               }
                            },
                            style: {
                               tip: true, // Give it a speech bubble tip with automatic corner detection
                               name: 'light',
                               background: '#F5DCB2',
                               border: {
                                   width: 7,
                                   radius: 5,
                                   color: '#CB8B21'
                                },
                               width: 600
                            }
               			});
                	}   
                	       	
                },
                emptyDataText: "<spring:message code='General.list.emptyrecords' />"
            }).jqGrid('filterToolbar', { searchOnEnter: true });          	
               
            function initPopup() {
                $("#editmodgridContainer").width(800); 
                $("#viewmodgridContainer").width(800); 
                $(".CaptionTD").width(200); 
                $("input.FormElement").width(560); 
            }

            function updatePreferedRowNum(newRowNum) {
                $.ajax({
                    type: "POST",
                    url: "${pageContext.request.contextPath}/book/updatePreferedGridRowNum.action",
                    data: {
                        newRowNum: newRowNum
                    },
                    success: function(jsonString) {}
                });
            }

            var timeoutHnd;
            function doSearch(ev) {
                if(timeoutHnd) {
                    clearTimeout(timeoutHnd);
                }
                timeoutHnd = setTimeout(gridReload, 500);
            }

            function gridReload() {
                var grid = $("#gridContainer");
                grid[0].triggerToolbar();
            }      
              

            jQuery("#gridContainer").jqGrid('navGrid',
                    '#pagerGridContainer', {
                        edit : true,
                        add : true,
                        view : true,
                        del : true,
                        search : false
                    },
                    // prmEdit, prmAdd, prmDel, prmSearch, prmView
                    {
                        closeAfterAdd: true,
                        closeAfterEdit: true,
                        viewPagerButtons: false,
                        modal: true,
                        width:500,
                        //top: 100,
                        //left: 100,
                        url:'management/update.action',
                        afterSubmit : DomainProcessor.processUpdateResponse,
                        ajaxEditOptions : {
                            type : 'POST',
                            contentType : 'application/json'
                        },
	                    serializeEditData: function(data) {
	                        return $.toJSON($.extend({}, data));
	                    },
                        beforeShowForm : function (formid) {
                        	initPopup();
                        }
                    },
                    {
                        closeAfterAdd: true,
                        closeAfterEdit: true,
                        viewPagerButtons: false,
                        modal: true,
                        width:500,
                        //top: 100,
                        //left: 100,
                        url:'management/insert.action',
                        afterSubmit : DomainProcessor.processInsertResponse,
                        ajaxEditOptions : {
                            type : 'POST',
                            contentType : 'application/json'
                        },
                        serializeEditData: function(data) {
                            return $.toJSON($.extend({}, data, {id:0}));
                        },
                        beforeShowForm : function (formid) {
                        	initPopup();
                        }
                    },
                    {
                        url:'management/delete.action'
                    },
                    {},
                    {
                    	viewPagerButtons: false,
                        beforeShowForm : function (formid) {
                        	initPopup();
                        }
                    }  // view
            );
        }
    };
}
    
</script>